package com.txts.road.app.map.controller;

import com.txts.road.app.map.model.vo.FavoritePlaceVO;
import com.txts.road.app.map.service.FavoritePlaceService;
import com.txts.base.common.domain.ResponseDTO;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.txts.road.app.map.model.dto.FavoritePlaceDTO;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;


/**
 * 收藏地点前端控制层
 *
 * @author baoyr
 * @since 2025-07-17 10:46
 */
@Tag(name = "收藏地点接口")
@RestController
@RequestMapping("/api/v1/favorite-place")
@RequiredArgsConstructor
public class FavoritePlaceController {
    private final FavoritePlaceService favoritePlaceService;

    /**
     * 添加收藏地点
     */
    @Operation(summary = "添加收藏地点")
    @PostMapping("/favorite/add")
    public ResponseDTO<Boolean> addFavoritePlace(@Valid @RequestBody FavoritePlaceDTO addDTO) {
        return ResponseDTO.ok(favoritePlaceService.addFavoritePlace(addDTO));
    }

    /**
     * 获取收藏地点列表
     */
    @Operation(summary = "获取收藏地点列表")
    @GetMapping("/favorite/list")
    public ResponseDTO<List<FavoritePlaceVO>> getFavoritePlaces() {
        return ResponseDTO.ok(favoritePlaceService.getFavoritePlaces());
    }

    /**
     * 删除收藏地点
     */
    @Operation(summary = "删除收藏地点")
    @DeleteMapping("/favorite/{favoriteId}")
    public ResponseDTO<Boolean> deleteFavoritePlace(@PathVariable Long favoriteId) {
        return ResponseDTO.ok(favoritePlaceService.deleteFavoritePlace(favoriteId));
    }
}

